//************************************************************************
/// <copyrigth>2024-2025 Corporation.All Rights Reserved</copyrigth>
/// <author>tangyingzhong</author>
/// <contact>tangyz114987@outlook.com</contact>
/// <version>v1.0.0</version>
/// <describe>
/// Cross-Platform directory
///</describe>
/// <date>2024/2/27</date>
///***********************************************************************
#ifndef DIRECTORY_H
#define DIRECTORY_H

#include <string>
#include "ModuleLoader/ModuleConfig.h"

namespace SystemTool
{
    class CLASS_ITEM Directory
    {
    public:
        // Create directory by recursive
        static bool Create(std::string strDirPath, bool bIsRecursively = true);

        // Delete directory by recursive
        static bool Delete(std::string strDirPath);

        // Rename directory
        static bool Rename(std::string strOldDirPath, std::string strNewDirPath, bool bIsOverWrite = true);

        // Copy directory
        static bool CopyTo(std::string strOldDirPath, std::string strNewDirPath);
 
        // Move directory
        static bool MoveTo(std::string strOldDirPath, std::string strNewDirPath);

        // Get temp dir path
        static std::string GetTempPath();

        // Get appdata dir path
        static std::string GetAppDataPath();

        // Get document dir path
        static std::string GetDocumentPath();

        // Get exe's dir path
        static std::string GetExcutablePath();

        // Get current work dir path
        static std::string GetCurWorkPath();

        // Trim the dir path
        static std::string TrimPath(std::string strPath);

        // Add "/" to the dir path and Change dir path's "\\" to "/"
        static std::string StandardPath(std::string strPath);

        // Get dir's total size
        static size_t GetDirSize(std::string strDirPath);

        // Get parent dir from a absolution path
        static std::string GetParentDirPath(std::string strDirPath);

        // Is dir empty
        static bool IsEmpty(std::string strDirPath);

        // Is dir existed
        static bool IsExisted(std::string strDirPath);

        // Get dir's all sub-dirs
        static bool GetAllSubDirs(std::string strDirPath,std::vector<std::string>& vDirTable);

        // Get dir's all sub-files
        static bool GetAllSubFiles(std::string strDirPath,std::vector<std::string>& vFileTable);

        // Get dir's time
        static std::string GetDirName(std::string strDirPath);

        // Get dir's time
        static size_t GetLastModifyTime(std::string strDirPath);

        // Set dir's time
        static void SetLastModifyTime(std::string strDirPath, size_t iModifyTime_Ms);

        // Set dir writable
        static void SetWritable(std::string strDirPath, bool bIsWritable = true);

        // Set dir read only
        static void SetReadonly(std::string strDirPath, bool bIsReadable = true);

        // Set dir excutable
        static void SetExcutable(std::string strDirPath, bool bIsExcutable = true);

        // Get total space of this disk containing this dir
        static unsigned long long GetTotalSpace(std::string strDirPath);

        // Get usable space of this disk containing this dir
        static unsigned long long GetUsableSpace(std::string strDirPath);
        
        // Get free space of this disk containing this dir
        static unsigned long long GetFreeSpace(std::string strDirPath);
    };
}

#endif // DIRECTORY_H
